﻿<!-- #include file="config.asp" -->
<!-- #include file="LANGUAGE/doc-asp.asp"-->
<!-- #include file="function.asp" -->
<%
'注册插件
Call RegisterPlugin("Couple","ActivePlugin_Couple")

Dim Couple_MalePriority_Count
Dim Couple_FemalePriority_Count

'具体的接口挂接
Function ActivePlugin_Couple()

	'左右数量控制
	Call Add_Filter_Plugin("Filter_Plugin_TArticleList_Build_Template","Couple_RndSexualityTags")
	Call Add_Filter_Plugin("Filter_Plugin_TGuestBook_Build_Template","Couple_RndSexualityGuestbook")
	Call Add_Filter_Plugin("Filter_Plugin_TArticle_Export_TemplateTags","Couple_SetSexuality")
	Call Add_Filter_Plugin("Filter_Plugin_TArticleList_ExportByMixed","Couple_SetQueryString")
	Call Add_Action_Plugin("Action_Plugin_TArticleList_ExportBar_Begin","Call Couple_RemoveAuthorID(intAuthorId)")
	Call Add_Action_Plugin("Action_Plugin_TArticleList_ExportByMixed_End","Call Couple_ExportCate(intPage,intCateId,dtmYearMonth,strTagsName,Title,Template_Article_Multi)")
	Call Add_Action_Plugin("Action_Plugin_TArticleList_ExportByCache_End","Call Couple_ExportIndex()")

	'加上二级菜单项与向导项
	Call Add_Response_Plugin("Response_Plugin_SiteInfo_SubMenu",Couple_MadeSubMenu())
	Call Add_Response_Plugin("Response_Plugin_ThemesMng_SubMenu",Couple_MadeSubMenu())
	Call Add_Response_Plugin("Response_Plugin_PluginMng_SubMenu",Couple_MadeSubMenu())
	Call Add_Action_Plugin("Action_Plugin_ThemesMng_Begin","Call Couple_Hint")

	'Action_Plugin_BlogReBuild_*_Begin
	Call Add_Action_Plugin("Action_Plugin_BlogReBuild_GuestComments_Begin","BlogReBuild_GuestComments=Couple_BlogReBuild_GuestComments:Exit Function")
	Call Add_Action_Plugin("Action_Plugin_BlogReBuild_Comments_Begin","BlogReBuild_Comments=Couple_BlogReBuild_Comments:Exit Function")
	Call Add_Action_Plugin("Action_Plugin_BlogReBuild_Tags_Begin","BlogReBuild_Tags=Couple_BlogReBuild_Tags:Exit Function")
	Call Add_Action_Plugin("Action_Plugin_BlogReBuild_Catalogs_Begin","BlogReBuild_Catalogs=Couple_BlogReBuild_Catalogs:Exit Function")
	Call Add_Action_Plugin("Action_Plugin_BlogReBuild_Archives_Begin","BlogReBuild_Archives=Couple_BlogReBuild_Archives:Exit Function")
	Call Add_Action_Plugin("Action_Plugin_BlogReBuild_Calendar_Begin","BlogReBuild_Calendar=Couple_BlogReBuild_Calendar:Exit Function")
	'Call Add_Action_Plugin("Action_Plugin_BlogReBuild_TrackBacks_Begin","Exit Function")
	Call Add_Action_Plugin("Action_Plugin_BlogReBuild_Previous_Begin","Exit Function")
	Call Add_Action_Plugin("Action_Plugin_BlogReBuild_Authors_Begin","Exit Function")

	'Action_Plugin_BuildAllCache_Begin
	Call Add_Action_Plugin("Action_Plugin_BuildAllCache_Begin","Call Couple_BlogReBuild_AllCache:Exit Function")

	'Action_Plugin_MakeFileReBuild_End
	Call Add_Action_Plugin("Action_Plugin_MakeFileReBuild_End","Call Couple_BuildCache")
	'Action_Plugin_MakeBlogReBuild_Begin
	Call Add_Action_Plugin("Action_Plugin_MakeBlogReBuild_Begin","Call Couple_BuildCache")
	'Action_Plugin_MakeBlogReBuild_Core_End ---New
	Call Add_Action_Plugin("Action_Plugin_MakeBlogReBuild_Core_Begin","Call Couple_BuildCache")

	'Filter_Plugin_PostArticle_Core
	Call Add_Filter_Plugin("Filter_Plugin_PostArticle_Core","Couple_DelCache")
	'Action_Plugin_Admin_Begin
	Call Add_Action_Plugin("Action_Plugin_Admin_Begin","Couple_IntegrityChk")

	'替换语言包
	Call Add_Filter_Plugin("Filter_Plugin_TArticleList_Build_Template","Couple_BuildLanguage_List")
	Call Add_Filter_Plugin("Filter_Plugin_TGuestBook_Build_Template","Couple_BuildLanguage_GuestBook")
	Call Add_Filter_Plugin("Filter_Plugin_TArticle_Export_Template","Couple_BuildLanguage_Single")
	Call Add_Filter_Plugin("Filter_Plugin_TArticle_Export_Template_Sub","Couple_BuildLanguage_Single_Sub")
	Call Add_Filter_Plugin("Filter_Plugin_TComment_MakeTemplate_Template","Couple_BuildLanguage_Comment")

End Function


function Couple_SetQueryString(ByRef intPage,ByRef intCateId,ByRef intAuthorId,ByRef dtmYearMonth,ByRef strTagsName,ByRef intType)

	Call CheckParameter(intPage,"int",1)
	Call CheckParameter(intCateId,"int",Empty)
	Call CheckParameter(intAuthorId,"int",Empty)
	Call CheckParameter(dtmYearMonth,"dtm",Empty)

	Dim strCatalogPriority, aryCatalogPriority

	If IsEmpty(intCateId) And IsEmpty(intAuthorId) And IsEmpty(dtmYearMonth) And IsEmpty(strTagsName) Then
		strCatalogPriority=LoadFromFile(BlogPath & "THEMES/"& ZC_BLOG_THEME &"/INCLUDE/index.html","utf-8")
	Else
		strCatalogPriority=Couple_CacheCatalogPriority(intCateId,intAuthorId,dtmYearMonth,strTagsName)
	End If

	If InStr(strCatalogPriority,",")>0 Then
		aryCatalogPriority=split(strCatalogPriority,",")
		'给双方文章数量赋值
		Couple_MalePriority_Count=CInt(aryCatalogPriority(1))
		Couple_FemalePriority_Count=CInt(aryCatalogPriority(3))
		'设置作者 ID 为文章数较多之作者, 以保证分页 Bar 之合理
		If Couple_MalePriority_Count >= Couple_FemalePriority_Count Then
			intAuthorId=Couple_MaleID
		Else
			intAuthorId=Couple_FemaleID
		End If
	End If

End Function

Function Couple_RemoveAuthorID(ByRef intAuthorId)
	If IsEmpty(Request.QueryString("auth")) Then
		intAuthorId=Empty
	End If
End Function

Function Couple_ExportCate(ByRef intPage,ByRef intCateId,ByRef dtmYearMonth,ByRef strTagsName,ByRef Title,ByRef Template_Article_Multi)

	Call Add_Filter_Plugin("Filter_Plugin_TArticleList_Build_TemplateSub","Couple_TemplateSubCate")

	Template_Article_Multi=Empty

	If Not IsEmpty(intCateId) Then
		On Error Resume Next
		Title=Categorys(intCateId).Name
		Err.Clear
	End if

End Function

Function Couple_ExportIndex()

	Call Add_Filter_Plugin("Filter_Plugin_TArticleList_Build_TemplateSub","Couple_TemplateSubIndex")

End Function


Function Couple_Hint()
	Call SetBlogHint_Custom("&raquo; 提示: 当前主题需进行配置后才能正常使用, <a href="""& ZC_BLOG_HOST &"/THEMES/"& ZC_BLOG_THEME &"/Plugin/main.asp"">点此进入配置选项</a>.")
End Function

Function Couple_MadeSubMenu()

	Couple_MadeSubMenu=MakeSubMenu("[情侣主题配置选项]",ZC_BLOG_HOST & "/THEMES/"& ZC_BLOG_THEME &"/Plugin/main.asp","m-left",False)
	Couple_MadeSubMenu=Couple_MadeSubMenu & "<script type=""text/javascript"" src="""& ZC_BLOG_HOST &"themes/"& ZC_BLOG_THEME &"/plugin/register/Register.js""></script><script type=""text/javascript"" src="""& ZC_BLOG_HOST &"themes/"& ZC_BLOG_THEME &"/plugin/register/ajax.asp""></script>"
	Couple_MadeSubMenu=Couple_MadeSubMenu & MakeSubMenu("[检查主题最新版本]","javascript:setMark();regManual('update')","m-left",False)

End Function

Function Couple_BuildCache()
	Call Couple_BuildNavBar()
	Call Couple_BuildIstop()
	Call Couple_BuildPrevious("Male",Couple_MaleID)
	Call Couple_BuildPrevious("Female",Couple_FemaleID)
	Call Couple_BuildHotPost("Male",Couple_MaleID)
	Call Couple_BuildHotPost("Female",Couple_FemaleID)
	Call Couple_BuildRandom("Male",Couple_MaleID)
	Call Couple_BuildRandom("Female",Couple_FemaleID)
	Call Couple_CacheCatalogPriority(Empty,Empty,Empty,Empty)
	'Call Couple_ClearCaches()
End Function


'安装插件
Function InstallPlugin_Couple
	On Error Resume Next

	'Copy include files
	Dim arySL : arySL=LoadIncludeFiles("/THEMES/"& ZC_BLOG_THEME &"/PLUGIN/INCLUDE/")
	Dim fso,s
	Set fso = Server.CreateObject("Scripting.FileSystemObject")
		For Each s In arySL
			If InStr(s,".")>0 And Not LCase(s)="index.html" Then
				If Not fso.FileExists(BlogPath & "/THEMES/"& ZC_BLOG_THEME &"/INCLUDE/"&s) Then
					fso.CopyFile (BlogPath & "/THEMES/"& ZC_BLOG_THEME &"/PLUGIN/INCLUDE/"&s), (BlogPath & "/THEMES/"& ZC_BLOG_THEME &"/INCLUDE/"&s)
				End If
			End If
		Next
	Set fso = Nothing

	'Change template dir
	Dim tmpSng
	tmpSng=LoadFromFile(BlogPath & "c_option.asp","utf-8")
	Call SaveValueForSetting(tmpSng,True,"String","ZC_TEMPLATE_DIRECTORY","AIBAO")
	Call SaveValueForSetting(tmpSng,True,"Numeric","ZC_RECENT_COMMENT_WORD_MAX","32")
	Call SaveToFile(BlogPath & "c_option.asp",tmpSng,"utf-8",False)

	Err.Clear
End Function

'卸载插件
Function UnInstallPlugin_Couple
	On Error Resume Next

	'Change template dir
	Dim tmpSng
	tmpSng=LoadFromFile(BlogPath & "c_option.asp","utf-8")
	Call SaveValueForSetting(tmpSng,True,"String","ZC_TEMPLATE_DIRECTORY","template")
	Call SaveToFile(BlogPath & "c_option.asp",tmpSng,"utf-8",False)

	Err.Clear
End Function
%>